<template>
	<view class="content" v-if="show==1">
		<swiper class="swiper" :style="'height:'+height+'px;'" indicator-dots="true" autoplay="true" interval="5000" duration="500" circular="true" indicator-active-color="#333">
			<swiper-item v-for="(a,index) in advert">
			  <image :src="a.image" @click="img" :data-index="index" class="slide-image" mode="widthFix"/>
			</swiper-item>
		</swiper>
		<view class="kecheng">
			<view class="kecheng2">
				<text>买家服务订单</text>
				<view class="kecheng2-1" @click="kc" data-stu='0'>
					全部<image src="../../static/right_2.png" mode="aspectFill"></image>
				</view>
			</view>
			<view class="kecheng3">
				<view class="kecheng3-1" @click="kc" data-stu='0'>
					<image src="../../static/images/order_1.png" mode="aspectFit"></image>
					<view class="kecheng3-1-1">全部</view>
				</view>
				<view class="kecheng3-1" @click="kc" data-stu='1'>
					<image src="../../static/images/order_2.png" mode="aspectFit"></image>
					<view class="kecheng3-1-1">待付款</view>
					<view class="jiaobiao" v-if="kecheng.dfk_count>0"><text>{{kecheng.dfk_count}}</text></view>
				</view>
				<view class="kecheng3-1" @click="kc" data-stu='2'>
					<image src="../../static/images/daifuwu.png" mode="aspectFit"></image>
					<view class="kecheng3-1-1">待服务</view>
					<view class="jiaobiao" v-if="kecheng.dsk_count>0"><text>{{kecheng.dsk_count}}</text></view>
				</view>
				<view class="kecheng3-1" @click="kc" data-stu='3'>
					<image src="../../static/images/order_4.png" mode="aspectFit"></image>
					<view class="kecheng3-1-1">待完成</view>
					<view class="jiaobiao" v-if="kecheng.dwc_count>0"><text>{{kecheng.dwc_count}}</text></view>
				</view>
				<view class="kecheng3-1" @click="kc" data-stu='4'>
					<image src="../../static/images/order_5.png" mode="aspectFit"></image>
					<view class="kecheng3-1-1">待评价</view>
					<view class="jiaobiao" v-if="kecheng.dpj_count>0"><text>{{kecheng.dpj_count}}</text></view>
				</view>
			</view>
			
		</view>
		<view class="fengexian" v-if="is_teacher==1"></view>
		<view class="kecheng" v-if="is_teacher==1">
			<view class="kecheng2">
				<text>卖家服务订单</text>
				<view class="kecheng2-1" @click="kc2" data-stu='0'>
					全部<image src="../../static/right_2.png" mode="aspectFill"></image>
				</view>
			</view>
			<view class="kecheng3">
				<view class="kecheng3-1" @click="kc2" data-stu='0'>
					<image src="../../static/images/order_1.png" mode="aspectFit"></image>
					<view class="kecheng3-1-1">全部</view>
				</view>
				<view class="kecheng3-1" @click="kc2" data-stu='1'>
					<image src="../../static/images/order_2.png" mode="aspectFit"></image>
					<view class="kecheng3-1-1">待付款</view>
					<view class="jiaobiao" v-if="kecheng2.dfk_count>0"><text>{{kecheng2.dfk_count}}</text></view>
				</view>
				<view class="kecheng3-1" @click="kc2" data-stu='2'>
					<image src="../../static/images/daifuwu.png" mode="aspectFit"></image>
					<view class="kecheng3-1-1">待服务</view>
					<view class="jiaobiao" v-if="kecheng2.dsk_count>0"><text>{{kecheng2.dsk_count}}</text></view>
				</view>
				<view class="kecheng3-1" @click="kc2" data-stu='3'>
					<image src="../../static/images/order_4.png" mode="aspectFit"></image>
					<view class="kecheng3-1-1">待完成</view>
					<view class="jiaobiao" v-if="kecheng2.dwc_count>0"><text>{{kecheng2.dwc_count}}</text></view>
				</view>
				<view class="kecheng3-1" @click="kc2" data-stu='4'>
					<image src="../../static/images/order_5.png" mode="aspectFit"></image>
					<view class="kecheng3-1-1">待评价</view>
					<view class="jiaobiao" v-if="kecheng2.dpj_count>0"><text>{{kecheng2.dpj_count}}</text></view>
				</view>
			</view>
			
		</view>
		<daohang count='3'></daohang>
	</view>
</template>

<script>
	var app=getApp();
	import daohang from "../../components/daohang.vue"
	export default {
		components: {
			daohang
		},
		data() {
			return {
				uid:0,
				show:0,
				advert:[],
				height:0,
				is_teacher:0,
				kecheng:[],
				kecheng2:[]
			}
		},
		onShow() {
			// #ifdef MP-WEIXIN
			uni.hideHomeButton();
			// #endif
			const uid = uni.getStorageSync('uid');
			if(app.isBlank(uid)==false){
				this.uid=uid;
			}else{
				this.uid=0;
			}
			var that=this;
			uni.getSystemInfo({
			    success: function (res) {
					that.height=res.windowWidth*(250/600);
			    }
			});
			this.getdata();
		},
		methods: {
			getdata(){
				var that=this;
				
				uni.request({
				    url: app.globalData.url+"index/order",
					method:"POST",
					dataType:"json",
					header: {
					    'content-type': 'application/x-www-form-urlencoded'
					},
				    data: {uid:that.uid},
				    success: (res) => {
						uni.hideLoading();
						if(res.data.code!=1){
							if(res.data.code==4000){
								uni.removeStorageSync('uid');
							}
							app.error_msg(res.data.msg);
						}
						that.kecheng=res.data.data.kecheng
						that.kecheng2=res.data.data.kecheng2
						that.is_teacher=res.data.data.is_teacher
						that.advert=res.data.data.advert
						that.show=1;
				    }
				});
			},
			kc(e){
				var id=e.currentTarget.dataset.stu;
				uni.navigateTo({
				    url: '/pages/order/index?stu='+id
				});
			},
			kc2(e){
				var id=e.currentTarget.dataset.stu;
				uni.navigateTo({
				    url: '/pages/torder/index?stu='+id
				});
			}
		}
	}
</script>

<style>
	.fengexian{width:100%;height:7px;background-color: #f3f3f3;}
	.jiaobiao text{transform: scale(0.7);font-size: 0.7rem;display: inline-block;}
	.jiaobiao{width:16px;height:16px;border-radius: 50%;background-color: red;color:#fff;text-align: center;line-height: 16px;position: absolute;top:-5px;right:20%;}
	.kecheng3-1-1{width:100%;height:20px;line-height: 16px;}
	.kecheng3-1 image{width:20px;height:20px;}
	.kecheng3-1{width:20%;height:40px;text-align: center;float: left;margin-top: 15px;margin-bottom: 15px;position: relative;}
	.kecheng3{width:100%;overflow: hidden;}
	.kecheng2-1 image{width:16px;height:16px;float: right;margin-top: 13px;}
	.kecheng2-1{display: inline-block;float: right;}
	.kecheng2 text{color:#333;font-weight: 550;}
	.kecheng2{width:94%;padding: 0px 3%;border-bottom: 1px #f3f3f3 solid;height:40px;overflow: hidden;line-height: 40px;}
	.kecheng{width:100%;}
	.swiper {
	  width: 100%;
	  margin-bottom: 10px;
	}
	.swiper image {
	  height: 100%;
	  width: 100%;
	}
</style>
